package com.motu.monstercity.server.game.userdata;

import com.motu.monstercity.server.game.commondata.act.ActTask;
import com.motu.monstercity.server.game.logic.ActDaysManager;
import com.motu.vertx.module.utility.model.EntityManager;
import com.motu.vertx.module.utility.toolset.TimeUtils;

/**
 * 作者: hxl
 * 日期: 2025-03-10 09:11:26
 * 备注: 用户限时任务表
 */
public class UserRankActTask extends UserRankActTaskModel {
    public UserRankActTask() {
        super();
    }
    public UserRankActTask(long userId, long round, int configId, int taskType) {
        super();
        putUserId(userId);
        putConfigId(configId);
        putTaskType(taskType);
        putRound(round);
        String listKey = EntityManager.getFieldJoinString(userId, configId);
        putActListKey(listKey);
    }

    public void reset() {
        ActTask task = ActDaysManager.getActTaskByType(taskType);
        if (task == null) {
            return;
        }
        if (task.getType() != ActTask.RESET_DAILY) {
            return;
        }
        if (!TimeUtils.isToday(resetTime)) {
            putCurP(0);
            putGetReward("");
            putResetTime(TimeUtils.getCurTime());
            update();
        }
    }

    public void checkReset(long round) {
        if (getRound() != round) {
            putCurP(0);
            putRound(round);
            update();
        }
    }

}
